﻿using System.Drawing;
using System.Windows.Forms;
namespace WenSkin.Controls
{
    [ToolboxBitmap(typeof(Control))]
    public partial class WenNotesLineBox : WenControl
    {
        public WenNotesLineBox()
        {
            InitializeComponent();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            PaintNotesLine(e);
        }

        //绘制线条和注释文字
        private void PaintNotesLine(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            //Rectangle rec = ClientRectangle;

            float middleY = Height / 2;


            var sizeStr = g.MeasureString(Text, Font);

            var recStr = new RectangleF(10, middleY - sizeStr.Height / 2, sizeStr.Width, sizeStr.Height);

            g.DrawLine(new Pen(new SolidBrush(ForeColor)), 0, middleY, 10 - 1, middleY);
            g.DrawLine(new Pen(new SolidBrush(ForeColor)), recStr.Width + 11, middleY, Width, middleY);

            g.FillRectangle(new SolidBrush(BackColor), recStr);

            //g.DrawString(Text, Font, Brushes.Black, recStr);
            DrawString(Text, g, recStr);
        }
    }
}
